import config from '@/utils/config';
import { request } from '@/utils/http';
import { API } from '../model/baseModel';
import {
  DynamicDataModel,
  DynamicMultipleModel,
  DynamicParamModel,
  FormDataModel,
  FormModel,
} from '../model/formModel';

/**
 * 获取表单设计信息
 * @param formId 表单id
 * @returns 表单设计信息
 */
export function getFormDesign(formId: string) {
  return request.get<API<FormModel>>(config.url.modelDesign + formId);
}

/**
 * 获取表单数据
 * @param instanceId 流程实例id
 * @returns 表单数据
 */
export function getFormData(instanceId: string) {
  return request.get<API<FormDataModel>>(config.url.modelData + instanceId);
}

/**
 * 查询表单某个字段的所有实例下的值
 * @param params 分组/表单/字段的id
 * @returns 动态数据
 */
export function getDynamicDatas(params: DynamicParamModel) {
  return request.post<API<DynamicDataModel[]>>(config.url.dynamicData, params);
}

/**
 * 获取动态数据源选项
 * @param params
 * @returns
 */
export function getDynamicDataMultiple(params: { proInstId: string; fieldIds: string[] }) {
  return request.post<API<DynamicMultipleModel[]>>(config.url.dynamicMultiple, params);
}
